package hethong;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
import javax.swing.JPasswordField;

import trangchu.TrangChu;

import dangnhap.FromDangNhap;

public class DoiMatKhau extends JDialog implements ActionListener {

	private JPanel plNorth,plCenter,plSouth,pl;
	private JLabel lblDoiMK;
	private JLabel lblMKCu;
	private JPasswordField txtMKCu;
	private JLabel lblMKMoi;
	private JPasswordField txtMKMoi;
	private JLabel lblNhapLaiMK;
	private JPasswordField txtNhapLaiMK;
	private JButton btnCapNhat;
	private JButton btnThoat;
	private static TrangChu trangchu;
	public static void main(String[] args) {
		try {
			DoiMatKhau dialog = new DoiMatKhau(trangchu);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	public DoiMatKhau(TrangChu trangchu) {
		FromDangNhap.rootPath = this.getClass().getResource("/").getPath();
		this.setTitle("Phần mềm quản lý bán hàng");
		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
	    setBounds((screenSize.width-373)/2, (screenSize.height-187)/2, 372, 194);
	    Image icon = Toolkit.getDefaultToolkit().getImage(FromDangNhap.rootPath+"images/TrangChu.gif");
        this.setIconImage(icon); 
		getContentPane().setLayout(new BorderLayout(0,0));
		plNorth = new JPanel();
		getContentPane().add(plNorth,BorderLayout.NORTH);
		plNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
		lblDoiMK = new JLabel("Thay Đổi Mật Khẩu ");
		lblDoiMK.setBounds(10, 2, 400, 30);
		lblDoiMK.setFont(new Font("Tahoma", 2, 12));
		lblDoiMK.setFont(new Font("Tahoma", 3, 18));		
		lblDoiMK.setForeground(Color.blue);
		plNorth.add(lblDoiMK);
		
		pl = new JPanel();		
		getContentPane().add(pl,BorderLayout.WEST);
		ImageIcon im = new ImageIcon(FromDangNhap.rootPath+"images/doimatkhau.gif");
		JLabel lblImage = new JLabel(im);
		pl.add(lblImage);
		
		
		plCenter = new JPanel();
		getContentPane().add(plCenter,BorderLayout.CENTER);
		plCenter.setLayout(new MigLayout("", "[][grow]", "[][][]"));
		
		lblMKCu = new JLabel("Mật khẩu cũ:");
		plCenter.add(lblMKCu, "cell 0 0,alignx left");
		
		txtMKCu = new JPasswordField();
		plCenter.add(txtMKCu, "cell 1 0,growx");
		txtMKCu.setColumns(10);
		
		lblMKMoi = new JLabel("Mật khẩu mới:");
		plCenter.add(lblMKMoi, "cell 0 1,alignx left");
		
		txtMKMoi = new JPasswordField();
		plCenter.add(txtMKMoi, "cell 1 1,growx");
		txtMKMoi.setColumns(10);
		
		lblNhapLaiMK = new JLabel("Nhập lại mật khẩu:");
		plCenter.add(lblNhapLaiMK, "cell 0 2,alignx left");
		
		txtNhapLaiMK = new JPasswordField();
		plCenter.add(txtNhapLaiMK, "cell 1 2,growx");
		txtNhapLaiMK.setColumns(10);
		
		plSouth = new JPanel();
		plSouth.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(plSouth,BorderLayout.SOUTH);
		
		btnCapNhat = new JButton("Cập Nhật",new ImageIcon(FromDangNhap.rootPath+"images/capnhat.gif"));
		plSouth.add(btnCapNhat);
		
		btnThoat = new JButton("Thoát",new ImageIcon(FromDangNhap.rootPath+"images/xoa1.gif"));
		plSouth.add(btnThoat);
		
		//dangkisk
		this.btnCapNhat.addActionListener(this);
		this.btnThoat.addActionListener(this);
	}


	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnThoat){
			dispose();
		}
		
	}

}
